<?php 
class SubjectCodeHandler{

public function subjectcodeAdd($subgr,$subject,$grade,$fee){

include 'db.php';
$x=new DbConnect();
$con=$x->getConnection();

$sql="insert into subject_code (sub_gr,grade,subject,c_fee) values('$subgr','$grade','$subject','$fee')";

mysql_query($sql,$con) or 
die(mysql_error());

$msg="Sccussfully Added";

return $msg;

}

public function getPageSearch($startrow,$limit){

$x=new Dbconnect();

$con=$x->getConnection();

$sql="select sub_gr,grade,subject,c_fee from subject_code order by sub_gr asc  Limit $startrow,$limit";

$result= mysql_query($sql,$con)or die(mysql_error()); 
return $result;
}

public function getSearch($startrow,$subsearch,$scat,$limit){ 
//include '../logic/Classes/db.php';

$x1=new Dbconnect();

$con=$x1->getConnection();

if($scat=="Subject"){

$sql="select sub_gr,grade,subject,c_fee from subject_code where subject like '$subsearch%' limit $startrow,$limit";

 }else{ 

$sql="select sub_gr,grade,subject,c_fee from subject_code where grade ='$subsearch' limit $startrow,$limit";
    }

$result= mysql_query($sql,$con)or die(mysql_error()); 
return $result;

}


public function getPaginationRow($subsearch,$scat){ 
include '../logic/Classes/db.php';

$x1=new Dbconnect();

$con=$x1->getConnection();

if($scat=="Subject"){

$sql="select sub_gr,grade,subject,c_fee from subject_code where  subject like '$subsearch%' ";

 }else{ 

$sql="select sub_gr,grade,subject,c_fee from subject_code where grade ='$subsearch' ";
}

$result= mysql_query($sql,$con)or die(mysql_error()); 
return $result;


}

public function getDelete($id){

include 'db.php';

$x=new DbConnect();

$conn=$x->getConnection();

$sql="DELETE FROM subject_code WHERE sub_gr='$id'";
mysql_query($sql,$conn);

$msgd="Deleted";
return $msgd;
}


public function subjectcodeUpdate($id,$subject,$grade,$fee){
		include 'db.php';
		$x=new DbConnect();
		$con=$x->getConnection();
		
$sql="update subject_code set subject='$subject',grade='$grade',c_fee='$fee' where sub_gr='$id' "; 		
		
mysql_query($sql,$con) or 
die(mysql_error());

$msg =" Record Successfully updated";

	return $msg;	
		
}










}



?>